# Maintainer: Andreas Radke <andyrtr@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=openjpeg2
pkgver=2.4.0
pkgrel=1
pkgdesc="An open source JPEG 2000 codec, version ${pkgver}"
arch=(x86_64)
license=('custom: BSD')
url="https://github.com/uclouvain/openjpeg"
makedepends=('cmake' 'doxygen')
depends=('zlib' 'libpng' 'libtiff' 'lcms2')
source=("$pkgname-$pkgver.tar.gz::https://github.com/uclouvain/openjpeg/archive/v$pkgver.tar.gz")
sha256sums=('8702ba68b442657f11aaeb2b338443ca8d5fb95b0d845757968a7be31ef7f16d')

prepare() {
  cd "${srcdir}"
  mkdir build
}

build() {
  cd "${srcdir}/build"

  cmake "../openjpeg-${pkgver}" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_SHARED_LIBS=ON \
    -DBUILD_STATIC_LIBS=OFF \
    -DBUILD_DOC=on

  make
}

package() {
  cd "${srcdir}/build"
  make DESTDIR="${pkgdir}" install
  
  install -m755 -d "${pkgdir}/usr/share/licenses/openjpeg2"
  mv "${pkgdir}"/usr/share/doc/openjpeg-*/LICENSE "${pkgdir}"/usr/share/licenses/openjpeg2
}
